home *** CD-ROM | disk | FTP | other *** search
- on giveDict which
- global gDictMode, gDictNum, gHasPressed
- highlightDictSpeaker(which)
- updateStage()
- set gDictMode to #CLICKPICT
- if which <> gDictNum then
- set gDictNum to 0
- end if
- set gHasPressed to 0
- giveResponse(which)
- set gDictMode to #CLICKSPEAKER
- end
-
- on handleDictKey
- global gType
- set realKey to " "
- set saveCommand to the commandDown
- set saveShift to the shiftDown
- set saveAlt to the optionDown
- if saveCommand then
- if (the key = "m") and (gType = #MAC) then
- toggleMenu()
- else
- if the key = "q" then
- goQuit()
- else
- if the key = RETURN then
- dontPassEvent()
- checkDictation()
- else
- if (gType = #PC) and (saveAlt = 1) then
- if the key = "<" then
- set realKey to "Ç"
- else
- if (the key = "N") and (saveShift = 1) then
- set realKey to "Ñ"
- else
- if the key = "," then
- set realKey to "ç"
- else
- if the key = "n" then
- set realKey to "├▒"
- else
- if the key = "s" then
- set realKey to "ß"
- else
- if the key = "1" then
- set realKey to "¡"
- else
- if the key = "/" then
- set realKey to "┬┐"
- else
- if the key = "]" then
- set realKey to "┬╗"
- else
- if the key = "[" then
- set realKey to "«"
- end if
- end if
- end if
- end if
- end if
- end if
- end if
- end if
- end if
- end if
- end if
- end if
- end if
- else
- if the key = ENTER then
- dontPassEvent()
- checkDictation()
- else
- if (gType = #PC) and (the key = "6") and (saveShift = 1) then
- dontPassEvent()
- end if
- if (gType = #PC) and ((charToNum(the key) - 65280) = 156) then
- set realKey to numToChar(156)
- end if
- end if
- end if
- if realKey <> " " then
- if the selStart = 0 then
- set beforeText to EMPTY
- else
- set beforeText to char 1 to the selStart of field "dict text"
- end if
- set afterText to char the selEnd + 1 to the number of chars in field "dict text" of field "dict text"
- put beforeText & realKey & afterText into field "dict text"
- set the selStart to the selStart + 1
- set the selEnd to the selStart
- end if
- end
-
- on checkDictation
- global gDictNum, gPage, gHasPressed
- highlight(33)
- cursor(4)
- updateStage()
- set gHasPressed to 0
- giveResponse(gDictNum)
- set c to the number of cast "chapter text items"
- set c to c + ((gPage - 1) * 4) + gDictNum - 1
- set firstErr to checkStrings(the text of cast 42, the text of cast c)
- if firstErr = 0 then
- alignYesNo(0, #YES)
- giveYeahSnd()
- else
- alignYesNo(0, #no)
- set the selStart to firstErr - 1
- set the selEnd to firstErr
- set the selStart to firstErr - 1
- set the selEnd to firstErr
- giveNoSnd()
- end if
- repeat while soundBusy(1)
- end repeat
- puppetSound(0)
- hideOverlay()
- cursor(-1)
- updateStage()
- unhighlight(33)
- end
-
- on checkStrings source, correct
- if filter(char 1 of source) = " " then
- set prevChar to " "
- set startNum to 2
- else
- set prevChar to EMPTY
- set startNum to 1
- end if
- set y to 0
- set lenSource to length(source)
- set lenCorrect to length(correct)
- repeat with x = startNum to lenSource
- set theChar to filter(char x of source)
- if not ((theChar = " ") and (prevChar = " ")) then
- set y to y + 1
- set ch to filter(char y of correct)
- repeat while (prevChar = " ") and (ch = " ") and (y <= lenCorrect)
- set y to y + 1
- set ch to filter(char y of correct)
- end repeat
- if y > lenCorrect then
- repeat with ix = x to lenSource
- set theChar to filter(char ix of source)
- if theChar <> " " then
- return x
- end if
- end repeat
- return 0
- else
- if charToNum(theChar) <> charToNum(ch) then
- return x
- end if
- end if
- set prevChar to theChar
- end if
- end repeat
- if y < lenCorrect then
- repeat with iy = y + 1 to lenCorrect
- set ch to filter(char iy of correct)
- if ch <> " " then
- return x
- end if
- end repeat
- end if
- return 0
- end
-
- on filter ch
- global gFilter
- return char charToNum(ch) of field gFilter
- end
-